<template>
	<view class="wrap">
		<view class="main" v-if="state">
			<view class="b-rich">
				<rich-text :nodes="contentRich"></rich-text>
			</view>
		</view>
		<!-- 加载中 -->
		<load-more :loadingType="loadingType" :loadingText="loadingText"></load-more>
	</view>
</template>

<script>
	import {
		getPageDetail
	} from '@/service/api/content.js'
	import {
		formatRichText
	} from '@/common/util.js'
	import mixinsCommon from '@/mixins/common.js'
	export default {
		mixins: [mixinsCommon],
		data() {
			return {
				state: null
			}
		},
		computed: {
			contentRich() {
				return formatRichText(this.state.content)
			}
		},
		onLoad(options) {
			getPageDetail(options.id).then(([err, res]) => {
				console.log('getPageDetail', err, res)
				if (!err) {
					this.loadingType = -1
					this.state = res
					uni.setNavigationBarTitle({
						title: res.name
					})
				} else {
					this.loadingType = 3
					this.loadingText = err.data.msg || '加载失败'
				}
			})
		}
	}
</script>

<style lang="scss">
	page {
		padding-bottom: env(safe-area-inset-bottom);
		background: $pq-bg-color;
	}

	.wrap {}

	.b-rich {
		background: #fff;
		font-size: 28upx;
    padding: 30upx;
	}
</style>
